package com.hk.controller;

import com.hk.Enume.OperationType;
import com.hk.Roledto.RoleDto;
import com.hk.annotation.AotoFile;
import com.hk.constant.LogConstaant;
import com.hk.core.R;
import com.hk.core.Result;
import com.hk.core.roleResult.PageRoleResult;

import com.hk.core.roleResult.RoleResult;
import com.hk.domain.SysRole;
import com.hk.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
//    分页条件查询角色
@GetMapping("list")
public PageRoleResult list(@ModelAttribute RoleDto roleDto){
   return roleService.list(roleDto);

}
//修改状态
    @AotoFile(value = OperationType.PUT,title = LogConstaant.ROLE_LOG)
@PutMapping("changeStatus")
public RoleResult changeStatus(@RequestBody SysRole sysRole){
    roleService.changeStatus(sysRole);

    return new RoleResult();
}
@GetMapping("/{roleId}")
public Result selectById(@PathVariable Integer roleId){

    return Result.success(roleService.selectById(roleId));
}
//根据ID删除
    @AotoFile(value = OperationType.DELETE,title = LogConstaant.ROLE_LOG)
@DeleteMapping("/{roleId}")
public Result deleteById(@PathVariable Integer roleId){
    roleService.deleteById(roleId);
    return Result.success();
}
}
